package com.example.sunflowers.data.repository

import androidx.lifecycle.LiveData
import cn.trans88.taxiappkotlin.ext.loge
import com.example.sunflowers.data.db.Plant
import com.example.sunflowers.data.db.PlantDao
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.withContext
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.concurrent.thread

/**
 *
 * @Author： LJH
 * @Time： 2024/1/26
 * @description：
 */
@Singleton
class PlantRepository @Inject constructor(
    private val plantDao:PlantDao
) {

    fun getPlants() = plantDao.getPlants()

    suspend fun getPlant(plantId: String) = withContext(Dispatchers.IO){
        val plantById = plantDao.getPlantById(plantId)
        "plantById : ${plantById.name}".loge()
        plantById
    }


    fun getPlantWithGrowZoneNumber(growZoneNumber: Int) = plantDao.getPlantsWithGrowZoneNumber(growZoneNumber)
}